package com.example.webview;

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.KeyEvent;
import android.view.Menu;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class MainActivity extends Activity
{

	private WebView webview;  
	@SuppressLint("SetJavaScriptEnabled")
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		webview = (WebView) findViewById(R.id.webview);
		WebSettings webSettings = webview.getSettings();
        //����WebView���ԣ��ܹ�ִ��Javascript�ű�  
		webSettings.setJavaScriptEnabled(true);  
		//���ÿ��Է����ļ�
        webSettings.setAllowFileAccess(true);
         //����֧������
        webSettings.setBuiltInZoomControls(true);
        //������Ҫ��ʾ����ҳ  
        webview.loadUrl("http://sm0598.net/api/Html/Kcb_show.html?userid=1492&Key=F59BD65F7EDAFB087A81D4DCA06C4910");
        //����Web��ͼ  
        webview.setWebViewClient(new webViewClient ());  
		
	}
	 

	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	@Override 
    //���û���  
    //����Activity���onKeyDown(int keyCoder,KeyEvent event)����  
    public boolean onKeyDown(int keyCode, KeyEvent event) {  
        if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {  
            webview.goBack(); //goBack()��ʾ����WebView����һҳ��  
            return true;  
        }  
        finish();//�����˳�����
        return false;  
    }  
      
    //Web��ͼ  
    private class webViewClient extends WebViewClient {  
        public boolean shouldOverrideUrlLoading(WebView view, String url) {  
            view.loadUrl(url);  
            return true;  
        }  
    }  

}
